import { axios } from '@/util';
import { QueryParams, Role, Response } from '@/types';
const urls = {
  roles: `role`,
};

export const getRoles = async (params: QueryParams): Promise<Response | undefined> => {
  return await axios.get(urls.roles, { params: params });
};

export const createRole = async (role: Role): Promise<Response | undefined> => {
  return await axios.post(urls.roles, role);
};

export const updateRole = async (role: Role): Promise<Response | undefined> => {
  return await axios.put(urls.roles, role);
};

export const assgin = async (role: string, permissions: string[]): Promise<Response | undefined> => {
  return await axios.put(urls.roles, { code: role, permissions });
};
